package com.lmk.qs.jdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class JDBCConnection {
    public static void main(String[] args) throws Exception {
        //1.导入jar包
        //2.注册驱动
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        //3.获取数据库连接
        Connection con= DriverManager.getConnection("jdbc:mysql://localhost:3306/stu","root","root");

        //4.定义SQL语句
        String sql="update student set s_name='张三'where s_name='丧偶'";
        //5.获取执行sql语句的对象
        Statement st=con.createStatement();
        //6.执行sql语句
        int count= st.executeUpdate(sql);
        //7.处理结果
        System.out.println(count);
        //8.释放资源
        st.close();
        con.close();




    }
}
